% corr2d.m
% created 02/04/2012
% Crown copyright
%
% Description: Returns correltation coefficient between two matrices
%
% @author Kevin O'Holleran <kevin.o-holleran@npl.co.uk>
%
% @param A - matrix
% @param B - matrix
%
% @return result - double
function [ result ] = corr2dscan(A,B,corrWidth)


[w,h] = size(A);
result = zeros(corrWidth,corrWidth);
x0 = round(corrWidth/2);
y0 = round(corrWidth/2);
As = A(x0:(w-x0),y0:(h-y0));
for i = 1:corrWidth
    xi = round(x0-corrWidth/2+i);
    for j = 1:corrWidth
        yj = round(y0-corrWidth/2+j);
        Bs = B(xi:(xi+w-corrWidth),yj:(yj+h-corrWidth));
        result(i,j) = corr2d(As,Bs);
    end
end

end

